<template>
	<view class="interflow">
		<view class="desc dFlex jCenter_aCenter">
			<view class="descIcon imgPublic">
				<image src="https://wx.gdxixiashi.com/public/images/home/tx@2x.png" mode="widthFix"></image>
			</view>
			<view class="info">
				<view class="title">洗匣士官方公众号</view>
				<view class="toast">更多官方资讯 更多福利优惠</view>
			</view>
			<view class="gf imgPublic">
				<image src="https://wx.gdxixiashi.com/public/images/home/guanfang@2x.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="code imgPublic">
			<image :src="imgDomain + datas.gongzhonghao" mode="widthFix"></image>
		</view>
		<view class="toast2">保存图片扫码关注公众号</view>
		<view class="btns">
			<view class="btn" @tap='saveImg'>保存图片到本地</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgDomain:getApp().globalData.imgDomain,
				datas:{},
			};
		},
		onLoad() {
			this.initData();
		},
		onShareAppMessage() {
			return{
				title:'洗匣士~您的家居窗帘清洗助手',
				path:'/pages/home?spreadId=' + (uni.getStorageSync('userId')?uni.getStorageSync('userId'):''),
				imageUrl:getApp().globalData.imgDomain+'public/logo.png',
				desc:'手机下单 | 专员取送 | 生态环保 | 轻奢洗护',
			}
		},
		onShareTimeline() {
			return{
				title:'洗匣士~您的家居窗帘清洗助手',
				path:'/pages/home?spreadId=' + (uni.getStorageSync('userId')?uni.getStorageSync('userId'):''),
				imageUrl:getApp().globalData.imgDomain+'public/logo.png',
				desc:'手机下单 | 专员取送 | 生态环保 | 轻奢洗护',
			}
		},
		methods:{
			initData(){
				this.tool.getData('User/about',{}).then(res=>{
					console.log(res);
					if(res){
						this.datas = res;
					}
				}).catch(err=>{
					console.log(err);
				})
			},
			// 保存图片到本地
			saveImg(){
				uni.downloadFile({
					url:this.imgDomain + this.datas.gongzhonghao,
					success: (op) => {
						if(op.tempFilePath){
							uni.saveImageToPhotosAlbum({
								filePath:op.tempFilePath,
								success: () => {
									uni.showToast({
										titleL:'图片已保存',
										icon:"success"
									})
								},
								fail: (err) => {
									uni.showToast({
										title:'图片保存失败',
										icon:"none"
									})
								}
							})
						}
					},
					fail:(err)=>{
						console.log(err);
						uni.showToast({
							title:'图片下载失败',
							icon:"none"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: white;
	}
	.interflow{
		padding: 24px 5%;
		box-sizing: border-box;
		.btns{
			width: 100%;
			position: fixed;
			left:0;
			bottom: 0;
			padding: 12px 4%;
			box-sizing: border-box;
			.btn{
				width: 100%;
				text-align: center;
				color: white;
				background: linear-gradient(0deg,#609ff8 0%, #1664ff 100%);
				border-radius: 50px;
				padding:12px 0;
			}
		}
		.code{
			width: 65%;
			margin: 60px auto 50px;
		}
		.toast2{
			text-align: center;
			color: #666666;
			font-size: 15px;
		}
		.desc{
			width: 100%;
			border: 1px solid #1664FF;
			padding: 18px 45px;
			box-sizing: border-box;
			border-radius: 4px;
			position: relative;
			.gf{
				width: 34px;
				position:absolute;
				top: 0;
				right: 0;
			}
			.info{
				flex: 1;
				font-size: 12px;
				color: #999999;
				.title{
					font-size: 16px;
					color: #313131;
					font-weight:bold;
					margin-bottom: 12px;
				}
			}
			.descIcon{
				width: 64px;
				height: 64px;
				margin-right: 16px;
			}
		}
	}
</style>
